{%- assign url_parts = page.url | split: '/' %}
{%- assign spec_name = url_parts[1] %}
{%- assign spec_version = url_parts[2] %}
{%- assign spec_page = url_parts[3] %}
{%- if site.data.versions[spec_name].versions[spec_version] %}
{%- assign versions = site.data.versions[spec_name].versions | sort %}
<select id="redirectSelect.{{include.laptop}}" class="select-dropdown p-1 mx-1 my-4 text-black opacity-80
  {{include.laptop}}
  {%- if include.green %} border-green-900 bg-transparent
  {%- else %} border-gray-400
  {%- endif %}">
{%- for item in versions reversed %}
  {%- if item[1].hidden %}
    {%- unless spec_version == item[0] or item[1].unhide_for contains spec_page %}
      {%- continue %}
    {%- endunless %}
  {%- endif %}
  {%- assign page_url_parts = page.url | split: '/' %}
  {%- assign page_url = page_url_parts | join: '/' %}
  {%- assign other_version = page_url | replace: spec_version, item[0] | relative_url %}
  {%- comment %}
    If the other version of the page doesn't exist disable the option
  {%- endcomment %}
  {%- assign p = site.pages | where_exp: "page", "page.url contains other_version" | first %}
  {%- if p and spec_version == item[0] %}
    {%- assign state = "selected" %}
  {%- elsif p %}
    {%- assign state = "" %}  
  {%- else %}
    {%- assign state = "disabled" %}
  {%- endif %}
<option {{ state }} value="{{ other_version }}" class="inline-block">{{item[1].name}}</option>
{%- endfor %}
</select>
<script>
    var selectEl = document.getElementById('redirectSelect.{{include.laptop}}');

    selectEl.onchange = function(){
        var goto = this.value;
        window.location = goto;

    };
</script>
{%- else %}
{%- comment %}invisible placeholder to keep layout constant{% endcomment -%}
<select id="redirectSelect.{{include.laptop}}" disabled class="select-dropdown p-1 mx-1 my-4 opacity-0
  {{include.laptop}}
  {%- if include.green %} border-green-900 bg-transparent
  {%- else %} border-gray-400
  {%- endif %}">
<option selected value="" class="inline-block"></option>
</select>
{%- endif %}
